#include <iostream>

class ArrayIterator {
	friend std::ostream &operator <<(std::ostream &os, const ArrayIterator &array);
public:
	ArrayIterator(int *current) : current(current) {}
	int &operator *() {return *current;}
	ArrayIterator operator ++();
	bool operator ==(const ArrayIterator &other) {return current == other.current;} 
	bool operator !=(const ArrayIterator &other) {return !(*this == other);}
private:
	int *current;
};

class Array {
	friend std::ostream &operator <<(std::ostream &os, const Array &array);
public:
	Array(int n, int *arr = 0);
	int length() const {return n;}
	ArrayIterator begin() {return ArrayIterator(buffer);}
	ArrayIterator end() {return ArrayIterator(buffer+n);}
private:
	int *buffer;
	int n;
};
